home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The X-Philes (2nd Revision)
/
The X-Philes Number 1 (1995).iso
/
xphiles
/
hp48hor1
/
pow2.doc
< prev
next >
Wrap
Text File
|
1995-03-31
|
690b
|
19 lines
A programming challenge, by Joseph K. Horn
How can you tell, WITH PERFECT ACCURACY, whether or not a number is exactly a
power of 2?
Try it: Write a program called POW2 which tests whether the number on level 1
is a perfect power of 2, and returns a 1 if true, and a 0 if false.
While enjoying dinner at Sizzler restaurant, a member of our local HP
Calculator Club set this challenge before us. Everybody came up with a
different answer. Before you look at mine (POW2 on this disk), come up
with one of your own. There are a hundred ways to do it; which is best?
By the way, test some difficult cases like 2^4, 2^16, and 2^39.
Have fun!
-jkh-